#include "rclcpp/rclcpp.hpp"
#include "robot_move_interface/srv/move_robot.hpp" //自定义的包
#include "std_msgs/msg/string.hpp"

class TestPackageNode : public rclcpp::Node {
public:
  TestPackageNode(std::string name) : rclcpp::Node(name) {
    RCLCPP_INFO(this->get_logger(), "node: %s is created", name.c_str());
    pub_ = this->create_publisher<std_msgs::msg::String>(
        "~/pub_topic", rclcpp::SystemDefaultsQoS());
    timer_ = this->create_wall_timer(
        std::chrono::milliseconds(1000),
        std::bind(&TestPackageNode::timer_callback, this)); // 1000ms
  }
  ~TestPackageNode() { RCLCPP_INFO(this->get_logger(), "node is destroyed"); }
  void timer_callback() {
    auto msg = std_msgs::msg::String();
    msg.data = "Hello, world!";
    RCLCPP_INFO(this->get_logger(), "publish: %s", msg.data.c_str());
    pub_->publish(msg);
  }

private:
  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
  rclcpp::TimerBase::SharedPtr timer_;
};

int main(int argc, char *argv[]) {
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<TestPackageNode>("test_package_node"));
  rclcpp::shutdown();
  return 0;
}